<h3>Compliance Info</h3>
<p>
  Compliance Policy on this dataset is inherited from it's parent dataset(s). To make modifications on the purge
  <br>
  policy on this page, please complete the Compliance Metadata on all of the parent datasets.
</p>

<hr class="nacho-divider">

<h4>Parent Dataset</h4>

{{#each upstreamsMetadata as |parent|}}
  <div class="upstream-dataset">
    <span class="upstream-dataset__compliance-status">
      {{tooltip-on-element
        text=(if hasResolvedCompliance "Compliance completed for parent dataset" "Please complete the Compliance on this parent dataset")
      }}

      {{#if hasResolvedCompliance}}
        {{fa-icon "check" class="upstream-dataset__compliance-status__complete"}}
      {{else}}
        {{fa-icon "exclamation" class="upstream-dataset__compliance-status__incomplete"}}
      {{/if}}
    </span>

    {{#link-to
      "datasets.dataset"
      "urn"
      (query-params urn=parent.urn)
      class="upstream-dataset__upstream-link"
    }}
      <strong>{{parent.nativeName}}</strong>
    {{/link-to}}

    {{#link-to
      "datasets.dataset"
      "urn"
      (query-params urn=parent.urn)
      class="upstream-dataset__upstream-link-chevron"
    }}
      <i class="glyphicon glyphicon-menu-right" aria-label="Navigate to upstream dataset"></i>
    {{/link-to}}
  </div>
{{/each}}

<header class="downstream-purge-policy-header">
  <h4>Compliance Purge Policy</h4>
  <div class="downstream-purge-policy__edit">
    {{#unless hasIncompleteUpstream}}
      <label for="downstream-purge-edit" class="downstream-purge-policy__edit--label">
        Modifying this will not affect the purge policy on the parent dataset
      </label>

      {{#if isReadOnly}}
        <button
          class="nacho-button nacho-button--large"
          id="downstream-purge-edit"
          onclick={{action "onEdit"}}>
          Edit
        </button>
      {{else}}
        <button
          class="nacho-button nacho-button--large"
          disabled={{not retention.purgeType}}
            onclick={{perform saveRetentionTask}}>

          {{#if saveRetentionTask.isRunning}}
            {{pendulum-ellipsis-animation}}
          {{else}}
            Save
          {{/if}}

        </button>
      {{/if}}
    {{/unless}}
  </div>

</header>

<div class="downstream-purge-policy">
  {{#if hasIncompleteUpstream}}
    <p class="downstream-purge-policy__no-policy">
      This dataset does not have a current compliance purge policy. To update, please complete the Compliance Metadata
      on the parent dataset(s).
    </p>
  {{else}}

    {{purge-policy
      isEditable=(not isReadOnly)
      platform=platform
      supportedPurgePolicies=supportedPurgePolicies
      purgeNote=retention.purgeNote
      defaultPurgePolicy=upstreamComplianceType
      purgePolicy=(readonly retention.purgeType)
      missingPolicyText="This dataset does not have a current compliance purge policy"
      onPolicyChange=onChange
    }}
  {{/if}}
</div>
